[分享][Hexo][Hexo + GitHub for Windows]

Hexo framework 搭配上 Github版本管理 外加 Github靜態網頁空間

  1. 首先先要有Github帳號
  2. 使用Github創建一個Repository,名為username.github.io
    (ex: username:blake31113=>Repository name: blake31113.github.io 一定要為這種格式Github才會幫你Generate Page)
  3. 修改在Hexo的Blog資料夾下的_config.yml成
    1
    2
    3
    4
    deploy:
    type: github
    repository: git@github.com:username/username.github.io.git
    branch: master
  4. 在Blog資料夾內輸入
    1
    hexo deploy

就大功告成囉

如果有SSH的錯誤發生

  1. 安裝Git,我是去這裡下載的,因為要使用Git Bash
  2. 打開Git Bash,檢查電腦上的ssh key,輸入
    1
    $ cd ~/.ssh
  3. 生成新的SSH key
    1
    $ ssh-keygen -t rsa -C "github email address"
  4. 會出現以下內容,可以直接按Enter,使用預設值
    1
    2
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

    1
    2
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
  5. 看到以下內容就代表成功了
    1
    2
    3
    Your identification has been saved in /c/Users/you/.ssh/id_rsa.
    The key fingerprint is:
    01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db email_address
  6. 將剛剛生成位置的id_rsa.pub複製內文後,新增到GitHub->Account Setting->SSH Keys上面去
  7. 使用Git Bash輸入以下指令,測驗是否成功
    1
    ssh -T git@github.com
  8. 使用Hexo 來Deploy到Github上,開啟Windows Prompt到blog資料夾,輸入
    1
    hexo deploy
  9. 在瀏覽器網指輸入:username.github.io,如果有內容代表成功囉